Skip to content

[MKT-846]:feat/new text for renewal#1958

Merged
jaaaaavier merged 4 commits into
masterfrom
feat/update-texts-for-annual-plan
May 18, 2026
Merged

[MKT-846]:feat/new text for renewal#1958
jaaaaavier merged 4 commits into
masterfrom
feat/update-texts-for-annual-plan

Conversation

@jaaaaavier
Copy link
Copy Markdown
Contributor

@jaaaaavier jaaaaavier commented May 14, 2026

Description

This PR introduces a change to the text displayed in annual plans regarding the renewal rate. Since we now offer a discount on monthly plans, we should display the current price and specify that it renews at price X.

Related Issues

Related Pull Requests

Checklist

  • Changes have been tested locally.
  • Unit tests have been written or updated as necessary.
  • The code adheres to the repository's coding standards.
  • Relevant documentation has been added or updated.
  • No new warnings or errors have been introduced.
  • SonarCloud issues have been reviewed and addressed.
  • QA Passed

Testing Process

Additional Notes

@jaaaaavier jaaaaavier self-assigned this May 14, 2026
@jaaaaavier jaaaaavier added the enhancement New feature or request label May 14, 2026
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented May 14, 2026

Deploying drive-web with  Cloudflare Pages  Cloudflare Pages

Latest commit: 89ce672
Status: ✅  Deploy successful!
Preview URL: https://7153dae2.drive-web.pages.dev
Branch Preview URL: https://feat-update-texts-for-annual.drive-web.pages.dev

View logs

@jaaaaavier jaaaaavier marked this pull request as ready for review May 15, 2026 13:17
@jaaaaavier jaaaaavier requested review from a team, CandelR, larryrider and xabg2 as code owners May 15, 2026 13:17
describe('Calculating final price of a product', () => {
it('When there is no coupon, returns base amount multiplied by users', () => {
expect(getProductAmount(10, 2)).toBe('20');
expect(getProductAmount(10, 2)).toBe('20.00');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to introduce decimals when they are 00? Is this approved from product? I recall last time I had to remove them if they were .00.

export const formatPrice = (price: number) => {
const formattedAmount = Number(price.toFixed(2));
return Number.isInteger(formattedAmount) ? formattedAmount.toString() : price.toFixed(2);
const truncated = Math.floor(Number(price.toFixed(8)) * 100) / 100;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we using toFixed(8) here? It looks arbitrary and makes the intent unclear.
If the goal is simply truncating to 2 decimals, Math.floor(price * 100) / 100 should be enough.
If this is a workaround for floating-point precision issues, it would be good to document it explicitly or use a more deterministic decimal handling approach.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Math.floor(price * 100) / 100 alone is unsafe. If price is the result of floating-point arithmetic, you can get values like 0.2999999999999 where * 100 gives 29.9999, and Math.floor then truncates to 29 instead of 30,a wrong result for what we want right now. The toFixed(8) neutralizes that noise by rounding to 8 decimal places first, resolving the imprecision before the floor. The alternative Math.floor(price * 100) / 100 would reproduce that exact bug for computed prices.

xabg2
xabg2 previously approved these changes May 18, 2026
@sonarqubecloud
Copy link
Copy Markdown

@jaaaaavier jaaaaavier requested a review from xabg2 May 18, 2026 06:52
@jaaaaavier jaaaaavier merged commit 29ee070 into master May 18, 2026
11 checks passed
@jaaaaavier jaaaaavier deleted the feat/update-texts-for-annual-plan branch May 18, 2026 09:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants